package xyz.wjwnya.scoring_module.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.wjwnya.common.auth.QueryReturnDate;
import xyz.wjwnya.common.auth.UserSessionData;
import xyz.wjwnya.scoring_module.dto.QueryScoreRequest;
import xyz.wjwnya.scoring_module.service.ScoreService;

import javax.servlet.http.HttpServletRequest;
/**
 * 综合评分服务相关接口
 * @author zwj
 */
@RestController
@RequestMapping("/scoring")
public class ScoreController {
    private final ScoreService queryScoreService;

    public ScoreController(ScoreService queryScoreService) {
        this.queryScoreService = queryScoreService;
    }
    //查询学生综合评分
    @PostMapping("/QueryPersonalScoreCondition")
    public QueryReturnDate QueryPersonalScoreCondition(@RequestBody @Validated QueryScoreRequest queryScoreRequest, HttpServletRequest request) {
        QueryReturnDate returnDate =  queryScoreService.QueryPersonalScoreCondition(
                (UserSessionData)request.getSession().getAttribute("session_data"),queryScoreRequest.getNumber(), queryScoreRequest.getPage(), queryScoreRequest.getCourseId(),queryScoreRequest.getProjectGrupId()
         );
        return returnDate;
    }
    //查询项目组综合评分
    @PostMapping("/QueryGroupScoreCondition")
    public QueryReturnDate QueryGroupScoreCondition(@RequestBody @Validated QueryScoreRequest queryScoreRequest, HttpServletRequest request) {
        QueryReturnDate returnDate =  queryScoreService.QueryGroupScoreCondition(
                (UserSessionData)request.getSession().getAttribute("session_data"),queryScoreRequest.getNumber(), queryScoreRequest.getPage(), queryScoreRequest.getCourseId(),queryScoreRequest.getProjectGrupId()
        );
        return returnDate;
    }
}
